import 'package:yurun_smartmerchants/models/good_list_entity.dart';

goodListEntityFromJson(GoodListEntity data, Map<String, dynamic> json) {
	if (json['number'] != null) {
		data.number = json['number']?.toInt();
	}
	if (json['last'] != null) {
		data.last = json['last'];
	}
	if (json['size'] != null) {
		data.size = json['size']?.toInt();
	}
	if (json['totalPages'] != null) {
		data.totalPages = json['totalPages']?.toInt();
	}
	if (json['content'] != null) {
		data.content = new List<GoodListContent>();
		(json['content'] as List).forEach((v) {
			data.content.add(new GoodListContent().fromJson(v));
		});
	}
	if (json['totalElements'] != null) {
		data.totalElements = json['totalElements']?.toInt();
	}
	return data;
}

Map<String, dynamic> goodListEntityToJson(GoodListEntity entity) {
	final Map<String, dynamic> data = new Map<String, dynamic>();
	data['number'] = entity.number;
	data['last'] = entity.last;
	data['size'] = entity.size;
	data['totalPages'] = entity.totalPages;
	if (entity.content != null) {
		data['content'] =  entity.content.map((v) => v.toJson()).toList();
	}
	data['totalElements'] = entity.totalElements;
	return data;
}

goodListContentFromJson(GoodListContent data, Map<String, dynamic> json) {
	if (json['quantity'] != null) {
		data.quantity = json['quantity']?.toString();
	}
	if (json['packageContainer'] != null) {
		data.packageContainer = json['packageContainer']?.toString();
	}
	if (json['packageUnit'] != null) {
		data.packageUnit = json['packageUnit']?.toString();
	}
	if (json['categoryiiId'] != null) {
		data.categoryiiId = json['categoryiiId']?.toInt();
	}
	if (json['inventory'] != null) {
		data.inventory = json['inventory']?.toString();
	}
	if (json['url'] != null) {
		data.url = json['url']?.toString();
	}
	if (json['categoryiiiName'] != null) {
		data.categoryiiiName = json['categoryiiiName']?.toString();
	}
	if (json['id'] != null) {
		data.id = json['id']?.toInt();
	}
	if (json['categoryiiiId'] != null) {
		data.categoryiiiId = json['categoryiiiId']?.toInt();
	}
	if (json['status'] != null) {
		data.status = json['status']?.toInt();
	}
	return data;
}

Map<String, dynamic> goodListContentToJson(GoodListContent entity) {
	final Map<String, dynamic> data = new Map<String, dynamic>();
	data['quantity'] = entity.quantity;
	data['packageContainer'] = entity.packageContainer;
	data['packageUnit'] = entity.packageUnit;
	data['categoryiiId'] = entity.categoryiiId;
	data['inventory'] = entity.inventory;
	data['url'] = entity.url;
	data['categoryiiiName'] = entity.categoryiiiName;
	data['id'] = entity.id;
	data['categoryiiiId'] = entity.categoryiiiId;
	data['status'] = entity.status;
	return data;
}